﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Net;

namespace Obra.Test
{
    class MatchedContentFile :
        IMatchedContent
    {
        private readonly Regex regex;
        private readonly String fileName;
        private readonly List<HttpListenerRequest> requests = new List<HttpListenerRequest>();

        /// <summary>
        /// c-tor
        /// </summary>
        public MatchedContentFile(
            string regex,
            string fileName)
        {
            this.regex = new Regex(regex);
            this.fileName = fileName;
        }

        #region IMatchedContent Members

        public List<HttpListenerRequest> Requests
        {
            get { return this.requests; }
        }

        public bool IsMatch(Uri uri)
        {
            return this.regex.IsMatch(uri.ToString());
        }

        public byte[] GetContent()
        {
            return File.ReadAllBytes(this.fileName);
        }

        #endregion
    }
}
